﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Xyz.Web.Reservation.Models.BookingModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Booking Summary
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Booking Summary</h2>

    <% using (Html.BeginForm("Bookingsummary", "Shoppingcart", FormMethod.Post, new { id = "bookingForm", enctype = "multipart/form-data" }))
       { %>

           <fieldset>
        <legend>Booking Info</legend>

        <table style="border: 1;  border-collapse: collapse; margin-left: 16px;">
            <tr>
                <td style="width: 140px;">Trip Code : </td>
                <td style="width: 100px; text-align: right;"><%: Model.TripCode %></td>
            </tr>
            <tr>
                <td>Status : </td>
                <td style="text-align: right;"><%: Model.Status %></td>
            </tr>
            <tr>
                <td>Booking Date : </td>
                <td style="text-align: right;"><%: String.Format("{0:dd-MMM-yyyy}", Model.BookingDate) %></td>
            </tr>
        </table>
        
 
    <br />
    <% decimal totalPrice = 0; %>
    <% foreach (var ticketModel in Model.Tickets)
       {  decimal ticketPrice = 0;%>
    <fieldset>
        <legend>Ticket Info</legend>
        
           
        <!--% Html.RenderPartial("FlightInfo", ticketModel.Flight); %-->
        <br />
      
        <table border: 1; border-collapse: collapse">
            <tr>
            <td style="width: 140px;">
            <% if (ticketModel.isDeparture == true)
              {%> Departure Flight :
           <% }
              else
              { %>
            Return Flight :
            <%} %>
            </td>
            <td style="width: 100px; text-align: right;">
            
                <%: ticketModel.Flight.FlightCode %>
            </td>
            
                <td style="width:110px; padding-left: 150px;">
                    Passenger Name :
                </td>
                <td style="width: 200px;">
                    <%: string.Concat(ticketModel.Passenger.LastName, " ", ticketModel.Passenger.FirstName)%>
                </td>
                <td style="width: 90px;">
                    Seat Number :
                </td>
                <td>
                <!--%: ticketModel.Seat.SeatNo%-->
                <%: ticketModel.SeatCode%>                 
                </td>
                </tr>
                <tr>
                <td colspan="6">&nbsp;</td>
                </tr>
                <tr>
                 <td style="width: 140px;">
            Flight Tax Surcharge :
            </td>
            <td style="width: 100px; text-align: right;">
              <%: ticketModel.Flight.TaxSurcharge%>
        <% ticketPrice += (decimal)ticketModel.Flight.TaxSurcharge; %>
            </td>
                </tr>
                <tr>
                 <td style="width: 100px;">
            Seat Price :
            </td>
                <td style="width: 100px; text-align:right;">
                <%: ticketModel.TicketFare%>
                <% ticketPrice += (decimal)ticketModel.TicketFare; %>
                </td>
            </tr>
           
              <tr><td>Addon Services</td></tr>
            
                <% foreach (var serviceModel in ticketModel.Services)
       {%>
       <%if (serviceModel != null)
         { %>
           <tr>
          <td style="width: 120px; padding-left:20px;">
                <%: serviceModel.ServiceDescription%>
        </td><td style="width: 100px; text-align: right;">
                 <%: serviceModel.Price%>
            </td>
            <% ticketPrice += (decimal)serviceModel.Price; %>
             </tr>
            <%}
             
       } %>
     
            <tr><td><br/></td></tr>
            <tr>
               <td style="width: 140px;">
            Ticket Price :
            </td>
            <td style="width: 100px; text-align: right; border-top: 1px solid #999999;">
            <%: ticketPrice %>
       <% totalPrice += ticketPrice; %>
       </td>
            </tr>
          
        </table>
    </fieldset>
    <% } %>
      
    <fieldset>
        <legend>Total Price</legend>
          <div style="text-align:right; width: 250px; font-weight: bold; font-size: 18px; color: #000000;"><%: totalPrice %></div>
       <%  Model.TotalTicketFare = totalPrice; %>
   </fieldset>


  
       <fieldset>
        <legend>Please Enter Contact Info</legend>
         <font color= "red"> <span id="contactError" ></span></font>
        <table>
        <tr>
       <td><%: Html.Label("Contact Name : * ")%></td><td> <%= Html.TextBox("contactName", "")%></td>
     
       </tr>
       <tr>
       <td><%: Html.Label("Contact Number : * ")%></td><td> <%= Html.TextBox("contactNo", "")%></td>
       
        </tr>
        <tr>
      <td> <%: Html.Label("Contact Email : * ")%></td><td> <%= Html.TextBox("contactEmail", "")%></td>
      
        </tr>
        </table>
   </fieldset>
  
    
      <input type="button" value=" Confirm " onclick="Validate()" class="yellow_button" />
        </fieldset>
       <br />
       <br />   
     <% } %>


   <script type="text/javascript">

       function Validate() {
           var contactName = document.getElementById('contactName').value;
           var contactNo = document.getElementById('contactNo').value;
           var contactEmail = document.getElementById('contactEmail').value;
           var contactError = document.getElementById('contactError');
           if (contactName == '') {

               contactError.innerHTML = "Please enter contact name!!!";

           }
           else if (contactNo == '') {

               contactError.innerHTML = "Please enter contact number!!!";

           } else if (contactEmail == '') {
               contactError.innerHTML = "Please enter contact email!!!";
           }
           else {
               contactError.innerHTML = "";
               $("#bookingForm").submit();

           }
       }

</script>

</asp:Content>
